//
//  HerosInfoScreen.cpp
//  FruitCrush
//
//  Created by gaoyu on 15/7/28.
//
//

#include "HerosInfoScreen.h"
#include "MapScreen.h"
#include "TitleMenuItem.h"
#include "ShowStringWidget.h"
#include "LocalizedStringGetter.h"
#include "PopupLayer.h"
#include "HeroUsed.h"

#define BACK_WIDTH    50
#define PROPERTY_WIDTH 40
#define PROPERTY_HEIGHT 50
#define PROPERTY_ICON_X 45

typedef enum {
	BackTag = 1,
	HeroInfoTag,
	HealthValueTag,
	SwordValueTag,
	FireValueTag,
	ArrowValueTag,
	LightValueTag,
	PreviousPageTag,
	NextPageTag,
	FightTag
} HeroPropertyTag;

HerosInfoScreen::HerosInfoScreen()
:heroType(0),HealthLabel(nullptr),SwordLabel(nullptr),FireLabel(nullptr),ArrowLabel(nullptr),LightLabel(nullptr),
 HealthGoldLabel(nullptr),SwordGoldLabel(nullptr),FireGoldLabel(nullptr),ArrowGoldLabel(nullptr),LightGoldLabel(nullptr),
 itemFightButtonLabel(nullptr)
{
}



Scene *HerosInfoScreen::createScene()
{
    auto scene = Scene::create();
    auto layer = HerosInfoScreen::create();
    scene->addChild(layer);
    return scene;
}

bool HerosInfoScreen::init()
{
    if (!Node::init()) {
        return false;
    }
    heroType = UserDefault::getInstance()->getIntegerForKey(HEROS_DATA_TYPE_KEY,-1);
    if(heroType < 0){
    	UserDefault::getInstance()->setIntegerForKey(HEROS_DATA_TYPE_KEY, HerosDataType1);
    	heroType = HerosDataType1;
    }
    bgInit();
    menuInit();
    heroInit();
    return true;
}

void HerosInfoScreen::bgInit()
{
    auto bg = Sprite::create("WinBg.png");
    bg->setAnchorPoint(Vec2::ZERO);
    bg->setPosition(Vec2::ZERO);
    this->addChild(bg);
}

void HerosInfoScreen::menuInit()
{
    Size winsize = Director::getInstance()->getWinSize();

    auto itemBack = TitleMenuItem::create("WinBackButton.png", "WinBackButton.png","WinBackButton.png", CC_CALLBACK_1(HerosInfoScreen::menuCallback, this));
    itemBack->setAnchorPoint(Vec2::ZERO);
    itemBack->setTag(BackTag);
    itemBack->setPosition(Point(winsize.width - BACK_WIDTH,winsize.height - BACK_WIDTH));

    auto itemHeroinfo = TitleMenuItem::create("InfoButton.png", "InfoButtonSelected.png","InfoButtonSelected.png", CC_CALLBACK_1(HerosInfoScreen::menuCallback, this));
    itemHeroinfo->setAnchorPoint(Vec2::ZERO);
    itemHeroinfo->setTag(HeroInfoTag);
    itemHeroinfo->setPosition(Vec2(winsize.width / 2 + winsize.width / 4, winsize.height / 2 + winsize.height / 4));

    auto menu = Menu::create(itemBack, itemHeroinfo, NULL);
    menu->setAnchorPoint(Vec2::ZERO);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu);
}

int HerosInfoScreen::setGoldHelp(int type, Ref *sender, HeroData *mHeroData){
	int maxGlod = GoldSaveModel::getInstance()->getGoldNum();//UserDefault::getInstance()->getIntegerForKey("GoldSaveKeyValue-Gold",-1);
	int value = GLOD_CEAL;//UserDefault::getInstance()->getIntegerForKey("healthGlodValue-beauty", GLOD_CEAL);

	switch (type) {
		case HealthValueType:
			value = UserDefault::getInstance()->getIntegerForKey("healthGlodValue-beauty", GLOD_CEAL);
			if(value < maxGlod){
				mHeroData->setHealthGlodValue(GLOD_CEAL);
				__String *healthStr = __String::create("");
				healthStr->initWithFormat("%d",mHeroData->getHealthGlodValue());
				HealthGoldLabel->setString(healthStr->getCString());
			}
			break;
		case SwordValueType:
			value = UserDefault::getInstance()->getIntegerForKey("swordGlodValue-beauty", GLOD_CEAL);
			if(value < maxGlod){
				mHeroData->setSwordGlodValue(GLOD_CEAL);
				__String *swordStr = __String::create("");
				swordStr->initWithFormat("%d",mHeroData->getSwordGlodValue());
				SwordGoldLabel->setString(swordStr->getCString());
			}
			break;
		case FireValueType:
			value = UserDefault::getInstance()->getIntegerForKey("fireGlodValue-beauty", GLOD_CEAL);
			if(value < maxGlod){
				mHeroData->setFireGlodValue(GLOD_CEAL);
				__String *fireStr = __String::create("");
				fireStr->initWithFormat("%d",mHeroData->getFireGlodValue());
				FireGoldLabel->setString(fireStr->getCString());
			}
			break;
		case ArrowValueType:
			value = UserDefault::getInstance()->getIntegerForKey("arrowGlodValue-beauty", GLOD_CEAL);
			if(value < maxGlod){
				mHeroData->setArrowGlodValue(GLOD_CEAL);
				__String *arrowStr = __String::create("");
				arrowStr->initWithFormat("%d",mHeroData->getArrowGlodValue());
				ArrowGoldLabel->setString(arrowStr->getCString());
			}
			break;
		case LightValueType:
			value = UserDefault::getInstance()->getIntegerForKey("lightGlodValue-beauty", GLOD_CEAL);
			if(value < maxGlod){
				mHeroData->setLightGlodValue(GLOD_CEAL);
				__String *lightStr = __String::create("");
				lightStr->initWithFormat("%d",mHeroData->getLightGlodValue());
				LightGoldLabel->setString(lightStr->getCString());
			}
			break;
		default:
			break;
	}
	if(value < maxGlod){
//		UserDefault::getInstance()->setIntegerForKey("GoldSaveKeyValue-Gold", maxGlod - value);
		GoldSaveModel::getInstance()->changeGoldNum(-value);
		return 1;
	}else{
	    TitleMenuItem *item = (TitleMenuItem*)sender;
	    Vec2 v = item->getPosition();

        auto *widget = ShowStringWidget::create();
        widget->setText(LocalizedStringGetter::getStringByKey("GoldLitterWorning"));
        widget->setPosition(v);
        widget->setTextColor(Color3B::RED);
        this->addChild(widget);
	}
	return 0;
}

void HerosInfoScreen::onClickWithHealth(Ref *sender){
	switch (heroType) {
		case 0:{
			if(setGoldHelp(HealthValueType, sender, HeroBeauty::getInstance()) == 1){
				HeroBeauty::getInstance()->setHealthLevelValue(HEALTH_CEAL);
				__String *healthStr = __String::create("");
				healthStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("HealthValue"),HeroBeauty::getInstance()->getHealthValue());
				HealthLabel->setString(healthStr->getCString());
			}
		}
			break;
		case 1:{
			if(setGoldHelp(HealthValueType, sender, HeroFighter::getInstance()) == 1){
				HeroFighter::getInstance()->setHealthLevelValue(HEALTH_CEAL);
				__String *healthStr = __String::create("");
				healthStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("HealthValue"),HeroFighter::getInstance()->getHealthValue());
				HealthLabel->setString(healthStr->getCString());
			}
		}
			break;
		default:
			break;
	}
}
void HerosInfoScreen::onClickWithSword(Ref *sender){
	switch (heroType) {
		case 0:{
			if(setGoldHelp(SwordValueType, sender, HeroBeauty::getInstance()) == 1){
				HeroBeauty::getInstance()->setSwordLevelValue(ATTACK_CEAL);
				__String *swordStr = __String::create("");
				swordStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("SwordValue"),HeroBeauty::getInstance()->getSwordValue());
				SwordLabel->setString(swordStr->getCString());
			}
		}
			break;
		case 1:{
			if(setGoldHelp(SwordValueType, sender, HeroFighter::getInstance()) == 1){
				HeroFighter::getInstance()->setSwordLevelValue(ATTACK_CEAL);
				__String *swordStr = __String::create("");
				swordStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("SwordValue"),HeroFighter::getInstance()->getSwordValue());
				SwordLabel->setString(swordStr->getCString());
			}
		}
			break;
		default:
			break;
	}
}
void HerosInfoScreen::onClickWithFire(Ref *sender){
	switch (heroType) {
		case 0:{
			if(setGoldHelp(FireValueType, sender, HeroBeauty::getInstance()) == 1){
				HeroBeauty::getInstance()->setFireLevelValue(ATTACK_CEAL);
				__String *fireStr = __String::create("");
				fireStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("FireValue"),HeroBeauty::getInstance()->getFireValue());
				FireLabel->setString(fireStr->getCString());
			}
		}
			break;
		case 1:{
			if(setGoldHelp(FireValueType, sender, HeroFighter::getInstance()) == 1){
				HeroFighter::getInstance()->setFireLevelValue(ATTACK_CEAL);
				__String *fireStr = __String::create("");
				fireStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("FireValue"),HeroFighter::getInstance()->getFireValue());
				FireLabel->setString(fireStr->getCString());
			}
		}
			break;
		default:
			break;
	}
}
void HerosInfoScreen::onClickWithArrow(Ref *sender){
	switch (heroType) {
		case 0:{
			if(setGoldHelp(ArrowValueType, sender, HeroBeauty::getInstance()) == 1){
				HeroBeauty::getInstance()->setArrowLevelValue(ATTACK_CEAL);
				__String *arrowStr = __String::create("");
				arrowStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("ArrowValue"),HeroBeauty::getInstance()->getArrowValue());
				ArrowLabel->setString(arrowStr->getCString());
			}
		}
			break;
		case 1:{
			if(setGoldHelp(ArrowValueType, sender, HeroFighter::getInstance()) == 1){
				HeroFighter::getInstance()->setArrowLevelValue(ATTACK_CEAL);
				__String *arrowStr = __String::create("");
				arrowStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("ArrowValue"),HeroFighter::getInstance()->getArrowValue());
				ArrowLabel->setString(arrowStr->getCString());
			}
		}
			break;
		default:
			break;
	}
}
void HerosInfoScreen::onClickWithLight(Ref *sender){
	switch (heroType) {
		case 0:{
			if(setGoldHelp(LightValueType, sender, HeroBeauty::getInstance()) == 1){
				HeroBeauty::getInstance()->setLightLevelValue(ATTACK_CEAL);
				__String *lightStr = __String::create("");
				lightStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("LightValue"),HeroBeauty::getInstance()->getLightValue());
				LightLabel->setString(lightStr->getCString());
			}
		}
			break;
		case 1:{
			if(setGoldHelp(LightValueType, sender, HeroFighter::getInstance()) == 1){
				HeroFighter::getInstance()->setLightLevelValue(ATTACK_CEAL);
				__String *lightStr = __String::create("");
				lightStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("LightValue"),HeroFighter::getInstance()->getLightValue());
				LightLabel->setString(lightStr->getCString());
			}
		}
			break;
		default:
			break;
	}
}
void HerosInfoScreen::menuCallback(Ref *sender)
{
    TitleMenuItem *item = (TitleMenuItem*)sender;

    switch (item->getTag()) {
		case BackTag:
			Director::getInstance()->popScene();
			break;
		case HeroInfoTag:
			popupLayer();
			break;
		case HealthValueTag:
			onClickWithHealth(sender);
			break;
		case SwordValueTag:
			onClickWithSword(sender);
			break;
		case FireValueTag:
			onClickWithFire(sender);
			break;
		case ArrowValueTag:
			onClickWithArrow(sender);
			break;
		case LightValueTag:
			onClickWithLight(sender);
			break;
		case PreviousPageTag:{
				UserDefault::getInstance()->setIntegerForKey("heroType",heroType - 1);
				Director::getInstance()->popScene();
		    	auto scene = HerosInfoScreen::createScene();
//		    	auto transition = TransitionShrinkGrow::create(0.5f, scene);
		        Director::getInstance()->pushScene(scene);
			}
			break;
		case NextPageTag:{
				UserDefault::getInstance()->setIntegerForKey("heroType",heroType + 1);
				Director::getInstance()->popScene();
		    	auto scene = HerosInfoScreen::createScene();
//		    	auto transition = TransitionShrinkGrow::create(0.5f, scene);
		        Director::getInstance()->pushScene(scene);
			}
			break;
		case FightTag:{
			if(UserDefault::getInstance()->getIntegerForKey(HEROS_FIGHT_TYPE_KEY, 0) != heroType){
				UserDefault::getInstance()->setIntegerForKey(HEROS_FIGHT_TYPE_KEY, heroType);
				itemFightButtonLabel->setString(LocalizedStringGetter::getStringByKey("FightedHero"));
				itemFightButtonLabel->setColor(Color3B::GREEN);
				HeroUsed::getInstance()->setHeroFightType(heroType);
			}
		}
			break;
		default:
			break;
	}
}

void HerosInfoScreen::initHealthLabel(Point midPos, HeroData *mHeroData)
{
	__String *healthStr = __String::create("");
	healthStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("HealthValue"),mHeroData->getHealthValue());
	HealthLabel = LabelTTF::create(healthStr->getCString(), "Arial", 24);
	HealthLabel->setPosition(midPos + Point(-PROPERTY_WIDTH, 0 + HIGH_OFFSET) );
	HealthLabel->setColor(Color3B::MAGENTA);
	this->addChild(HealthLabel);
}

void HerosInfoScreen::initSwordLabel(Point midPos, HeroData *mHeroData)
{
	__String *swordStr = __String::create("");
	swordStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("SwordValue"),mHeroData->getSwordValue());
	SwordLabel = LabelTTF::create(swordStr->getCString(), "Arial", 24);
	SwordLabel->setPosition(midPos + Point(-PROPERTY_WIDTH, -1 * PROPERTY_HEIGHT + HIGH_OFFSET) );
	SwordLabel->setColor(Color3B::MAGENTA);
	this->addChild(SwordLabel);
}

void HerosInfoScreen::initFireLabel(Point midPos, HeroData *mHeroData)
{
	__String *fireStr = __String::create("");
	fireStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("FireValue"),mHeroData->getFireValue());
	FireLabel = LabelTTF::create(fireStr->getCString(), "Arial", 24);
	FireLabel->setPosition(midPos + Point(-PROPERTY_WIDTH, -2 * PROPERTY_HEIGHT + HIGH_OFFSET) );
	FireLabel->setColor(Color3B::MAGENTA);
	this->addChild(FireLabel);
}

void HerosInfoScreen::initArrowLabel(Point midPos, HeroData *mHeroData)
{
	__String *arrowStr = __String::create("");
	arrowStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("ArrowValue"),mHeroData->getArrowValue());
	ArrowLabel = LabelTTF::create(arrowStr->getCString(), "Arial", 24);
	ArrowLabel->setPosition(midPos + Point(-PROPERTY_WIDTH, -3 * PROPERTY_HEIGHT + HIGH_OFFSET) );
	ArrowLabel->setColor(Color3B::MAGENTA);
	this->addChild(ArrowLabel);
}

void HerosInfoScreen::initLightLabel(Point midPos, HeroData *mHeroData)
{
	__String *lightStr = __String::create("");
	lightStr->initWithFormat("%s%d",LocalizedStringGetter::getStringByKey("LightValue"),mHeroData->getLightValue());
	LightLabel = LabelTTF::create(lightStr->getCString(), "Arial", 24);
	LightLabel->setPosition(midPos + Point(-PROPERTY_WIDTH, -4 * PROPERTY_HEIGHT + HIGH_OFFSET) );
	LightLabel->setColor(Color3B::MAGENTA);
	this->addChild(LightLabel);
}

void HerosInfoScreen::heroInit()
{
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point midPos = Point(visibleSize.width/2, visibleSize.height/2);
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    
    auto cache = SpriteFrameCache::getInstance();
	cache->addSpriteFramesWithFile("Heros.plist");

	__String *fileName = __String::createWithFormat("Hero%d.png",heroType + 1);
	auto hero = Sprite::createWithSpriteFrameName(fileName->getCString());
	hero->setAnchorPoint(Vec2::ZERO);
	hero->setPosition(Vec2(visibleSize.width / 2 - hero->getContentSize().width / 2,
			visibleSize.height/2 + hero->getContentSize().height / 2 + HIGH_OFFSET));

	this->addChild(hero);

	switch (heroType) {
		case 0:{
			HeroBeauty *mHeroBeauty = HeroBeauty::getInstance();
			initHealthLabel(midPos,mHeroBeauty);
			initSwordLabel(midPos,mHeroBeauty);
			initFireLabel(midPos,mHeroBeauty);
			initArrowLabel(midPos,mHeroBeauty);
			initLightLabel(midPos,mHeroBeauty);
			goldLabelInit(midPos,mHeroBeauty);
		}
		break;
		case 1:{
			HeroFighter *mHeroFight = HeroFighter::getInstance();
			initHealthLabel(midPos,mHeroFight);
			initSwordLabel(midPos,mHeroFight);
			initFireLabel(midPos,mHeroFight);
			initArrowLabel(midPos,mHeroFight);
			initLightLabel(midPos,mHeroFight);
			goldLabelInit(midPos,mHeroFight);
		}
		break;
		default:
			break;
	}
	upButtonInit(midPos);
	goldIconInit(midPos);
	propertyIconInit(midPos);
	//bottomButtonInit(midPos);
}

void HerosInfoScreen::bottomButtonInit(Point midPos)
{
    auto itemPreviousPage = TitleMenuItem::create("WinButtonBg.png", "WinButtonSelected.png","WinButtonBg.png", CC_CALLBACK_1(HerosInfoScreen::menuCallback, this));
    itemPreviousPage->setAnchorPoint(Vec2::ANCHOR_BOTTOM_RIGHT);
    itemPreviousPage->setTag(PreviousPageTag);
    itemPreviousPage->setTitle(LocalizedStringGetter::getStringByKey("PreviousHero"), Size(BUTTON_WIDTH,BUTTON_HEIGHT));
    itemPreviousPage->setPosition(midPos + Point(0, -5 * PROPERTY_HEIGHT));
    if(heroType == 0){
    	itemPreviousPage->setVisible(false);
    }

    auto itemNextPage = TitleMenuItem::create("WinButtonBg.png", "WinButtonSelected.png","WinButtonBg.png", CC_CALLBACK_1(HerosInfoScreen::menuCallback, this));
    itemNextPage->setAnchorPoint(Vec2::ZERO);
    itemNextPage->setTag(NextPageTag);
    itemNextPage->setTitle(LocalizedStringGetter::getStringByKey("NextHero"), Size(BUTTON_WIDTH,BUTTON_HEIGHT));
    itemNextPage->setPosition(midPos + Point(0, -5 * PROPERTY_HEIGHT));
    if(heroType == 1){
    	itemNextPage->setVisible(false);
    }

    auto itemFightButton = TitleMenuItem::create("WinButtonBg.png", "WinButtonSelected.png","WinButtonBg.png", CC_CALLBACK_1(HerosInfoScreen::menuCallback, this));
    itemFightButton->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
    itemFightButton->setTag(FightTag);
    itemFightButton->setPosition(midPos + Point(0, 5 * PROPERTY_HEIGHT - HIGH_OFFSET));

    auto menu = Menu::create(itemPreviousPage, itemNextPage, itemFightButton, NULL);
    menu->setAnchorPoint(Vec2::ZERO);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu);

    int fightHeroType = UserDefault::getInstance()->getIntegerForKey(HEROS_FIGHT_TYPE_KEY, 0);
    if(fightHeroType == heroType){
    	itemFightButtonLabel = LabelTTF::create(LocalizedStringGetter::getStringByKey("FightedHero"), "arial", 20);
    	itemFightButtonLabel->setColor(Color3B::GREEN);
    }else{
    	itemFightButtonLabel = LabelTTF::create(LocalizedStringGetter::getStringByKey("FightHero"), "arial", 20);
    	itemFightButtonLabel->setColor(Color3B::WHITE);
    }
    itemFightButtonLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
    itemFightButtonLabel->setPosition(midPos + Point(0, 5 * PROPERTY_HEIGHT - HIGH_OFFSET));
    this->addChild(itemFightButtonLabel);
}

void HerosInfoScreen::upButtonInit(Point midPos)
{
    auto itemHealth = TitleMenuItem::create("LevelUpButtonNormal.png", "LevelUpButtonSelected.png","LevelUpButtonDisable.png", CC_CALLBACK_1(HerosInfoScreen::menuCallback, this));
    itemHealth->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
    itemHealth->setTag(HealthValueTag);
    itemHealth->setPosition(midPos + Point(2 * PROPERTY_WIDTH, 0 + HIGH_OFFSET));

    auto itemSword = TitleMenuItem::create("LevelUpButtonNormal.png", "LevelUpButtonSelected.png","LevelUpButtonDisable.png", CC_CALLBACK_1(HerosInfoScreen::menuCallback, this));
    itemSword->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
    itemSword->setTag(SwordValueTag);
    itemSword->setPosition(midPos + Point(2 * PROPERTY_WIDTH, -1 * PROPERTY_HEIGHT + HIGH_OFFSET));

    auto itemFire = TitleMenuItem::create("LevelUpButtonNormal.png", "LevelUpButtonSelected.png","LevelUpButtonDisable.png", CC_CALLBACK_1(HerosInfoScreen::menuCallback, this));
    itemFire->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
    itemFire->setTag(FireValueTag);
    itemFire->setPosition(midPos + Point(2 * PROPERTY_WIDTH, -2 * PROPERTY_HEIGHT + HIGH_OFFSET));

    auto itemArrow = TitleMenuItem::create("LevelUpButtonNormal.png", "LevelUpButtonSelected.png","LevelUpButtonDisable.png", CC_CALLBACK_1(HerosInfoScreen::menuCallback, this));
    itemArrow->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
    itemArrow->setTag(ArrowValueTag);
    itemArrow->setPosition(midPos + Point(2 * PROPERTY_WIDTH, -3 * PROPERTY_HEIGHT + HIGH_OFFSET));

    auto itemLight = TitleMenuItem::create("LevelUpButtonNormal.png", "LevelUpButtonSelected.png","LevelUpButtonDisable.png", CC_CALLBACK_1(HerosInfoScreen::menuCallback, this));
    itemLight->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
    itemLight->setTag(LightValueTag);
    itemLight->setPosition(midPos + Point(2 * PROPERTY_WIDTH, -4 * PROPERTY_HEIGHT + HIGH_OFFSET));

    auto menu = Menu::create(itemHealth, itemSword, itemFire, itemArrow, itemLight, NULL);
    menu->setAnchorPoint(Vec2::ZERO);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu);
}

void HerosInfoScreen::goldIconInit(Point midPos)
{
    auto cache = SpriteFrameCache::getInstance();
	cache->addSpriteFramesWithFile("CommonIcon.plist");
	__String *fileName = __String::createWithFormat("GoldIcon%d.png",26);

	auto health_gold = Sprite::createWithSpriteFrameName(fileName->getCString());
	health_gold->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM);
	health_gold->setPosition(midPos + Point(1 * PROPERTY_WIDTH, 0 + HIGH_OFFSET));

	auto sword_gold = Sprite::createWithSpriteFrameName(fileName->getCString());
	sword_gold->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM);
	sword_gold->setPosition(midPos + Point(1 * PROPERTY_WIDTH, -1 * PROPERTY_HEIGHT + HIGH_OFFSET));

	auto fire_gold = Sprite::createWithSpriteFrameName(fileName->getCString());
	fire_gold->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM);
	fire_gold->setPosition(midPos + Point(1 * PROPERTY_WIDTH, -2 * PROPERTY_HEIGHT + HIGH_OFFSET));

	auto arrow_gold = Sprite::createWithSpriteFrameName(fileName->getCString());
	arrow_gold->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM);
	arrow_gold->setPosition(midPos + Point(1 * PROPERTY_WIDTH, -3 * PROPERTY_HEIGHT + HIGH_OFFSET));

	auto light_gold = Sprite::createWithSpriteFrameName(fileName->getCString());
	light_gold->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM);
	light_gold->setPosition(midPos + Point(1 * PROPERTY_WIDTH, -4 * PROPERTY_HEIGHT + HIGH_OFFSET));

	this->addChild(health_gold);
	this->addChild(sword_gold);
	this->addChild(fire_gold);
	this->addChild(arrow_gold);
	this->addChild(light_gold);
}

void HerosInfoScreen::propertyIconInit(Point midPos)
{
    auto cache = SpriteFrameCache::getInstance();
	cache->addSpriteFramesWithFile("Unit.plist");

	auto health = Sprite::createWithSpriteFrameName("Health.png");
	health->setPosition(PROPERTY_ICON_X,midPos.y - 0 * PROPERTY_HEIGHT+ HIGH_OFFSET);

	auto sword = Sprite::createWithSpriteFrameName("Sword.png");
	sword->setPosition(PROPERTY_ICON_X,midPos.y -1 * PROPERTY_HEIGHT+ HIGH_OFFSET);

	auto fire = Sprite::createWithSpriteFrameName("Fire.png");
	fire->setPosition(PROPERTY_ICON_X,midPos.y -2 * PROPERTY_HEIGHT+ HIGH_OFFSET);

	auto arrow = Sprite::createWithSpriteFrameName("Arrow.png");
	arrow->setPosition(PROPERTY_ICON_X,midPos.y - 3 * PROPERTY_HEIGHT+ HIGH_OFFSET);

	auto light = Sprite::createWithSpriteFrameName("Light.png");
	light->setPosition(PROPERTY_ICON_X,midPos.y - 4 * PROPERTY_HEIGHT+ HIGH_OFFSET);

	this->addChild(health);
	this->addChild(sword);
	this->addChild(fire);
	this->addChild(arrow);
	this->addChild(light);
}

void HerosInfoScreen::goldLabelInit(Point midPos,HeroData *mHeroData)
{
	__String *healthStr = __String::create("");
	healthStr->initWithFormat("%d",mHeroData->getHealthGlodValue());
	HealthGoldLabel = LabelTTF::create(healthStr->getCString(), "Arial", 10);
	HealthGoldLabel->setPosition(midPos + Point(1 * PROPERTY_WIDTH, 0 * PROPERTY_HEIGHT - 5 + HIGH_OFFSET));
	HealthGoldLabel->setColor(Color3B::WHITE);
	this->addChild(HealthGoldLabel);

	__String *swordStr = __String::create("");
	swordStr->initWithFormat("%d",mHeroData->getSwordGlodValue());
	SwordGoldLabel = LabelTTF::create(swordStr->getCString(), "Arial", 10);
	SwordGoldLabel->setPosition(midPos + Point(1 * PROPERTY_WIDTH, -1 * PROPERTY_HEIGHT - 5 + HIGH_OFFSET));
	SwordGoldLabel->setColor(Color3B::WHITE);
	this->addChild(SwordGoldLabel);

	__String *fireStr = __String::create("");
	fireStr->initWithFormat("%d",mHeroData->getFireGlodValue());
	FireGoldLabel = LabelTTF::create(fireStr->getCString(), "Arial", 10);
	FireGoldLabel->setPosition(midPos + Point(1 * PROPERTY_WIDTH, -2 * PROPERTY_HEIGHT - 5 + HIGH_OFFSET));
	FireGoldLabel->setColor(Color3B::WHITE);
	this->addChild(FireGoldLabel);

	__String *arrowStr = __String::create("");
	arrowStr->initWithFormat("%d",mHeroData->getArrowGlodValue());
	ArrowGoldLabel = LabelTTF::create(arrowStr->getCString(), "Arial", 10);
	ArrowGoldLabel->setPosition(midPos + Point(1 * PROPERTY_WIDTH, -3 * PROPERTY_HEIGHT - 5 + HIGH_OFFSET));
	ArrowGoldLabel->setColor(Color3B::WHITE);
	this->addChild(ArrowGoldLabel);

	__String *lightStr = __String::create("");
	lightStr->initWithFormat("%d",mHeroData->getLightGlodValue());
	LightGoldLabel = LabelTTF::create(lightStr->getCString(), "Arial", 10);
	LightGoldLabel->setPosition(midPos + Point(1 * PROPERTY_WIDTH, -4 * PROPERTY_HEIGHT - 5 + HIGH_OFFSET));
	LightGoldLabel->setColor(Color3B::WHITE);
	this->addChild(LightGoldLabel);
}

void HerosInfoScreen::popupLayer(){
	switch (heroType) {
		case 0:{
			PopupLayer* popLayer = PopupLayer::create();
//			popLayer->setTitle(LocalizedStringGetter::getStringByKey("NextHero"));
			popLayer->setContent(LocalizedStringGetter::getStringByKey("HeroOneInfo"));
			this->addChild(popLayer);
		}
			break;
		case 1:{
			PopupLayer* popLayer = PopupLayer::create();
			popLayer->setContent(LocalizedStringGetter::getStringByKey("HeroTwoInfo"));
			this->addChild(popLayer);
		}
			break;
		default:
			break;
	}

}
